/*
 This file 'zdwxyApp' is part of Firebird Integrated Solution 1.0

 Copyright (c) 2020 Lincong

 Contact:  
        Email: lincong1987@gmail.com

        QQ: 159257119
 
 See Usage at http://www.jplatformx.com/firebird

 Create date: 2020-06-14 20:46
 */

define(function (require, exports, module) {
	require("Firebird.App");
	require("Firebird.Controller");
	// require("Format");

	require("../assets/flop");
	require("../assets/sub-header");
	require("../assets/header-datetime");

	var zdwxy_1 = require("./zdwxy_1");
	var zdwxy_2 = require("./zdwxy_2");
	var zdwxy_3 = require("./zdwxy_3");
	var zdwxy_5 = require("./zdwxy_5");
	var zdwxy_6 = require("./zdwxy_6");
	var zdwxy_7 = require("./zdwxy_7");
	var zdwxy_8_chart_1 = require("./zdwxy_8_chart_1");
	var zdwxy_8_chart_2 = require("./zdwxy_8_chart_2");

	var controller = Firebird.create("Firebird.Controller", {
		controller: "{contextPath}/publicMain"
	});

	Firebird.define("zdwxy.SearchApp", {
		extend: "Firebird.SearchApp",
		controller: controller,
		setContext: function () {
			var app = this, context = this.context;

			// this.showOnline();
			context.zdwxy_1 = zdwxy_1;
			context.zdwxy_2 = zdwxy_2;
			context.zdwxy_3 = zdwxy_3;
			context.zdwxy_5 = zdwxy_5;
			context.zdwxy_6 = zdwxy_6;
			context.zdwxy_7 = zdwxy_7;

			context.zdwxy_8_chart_1 = zdwxy_8_chart_1;
			context.zdwxy_8_chart_2 = zdwxy_8_chart_2;


			zdwxy_1.setValue([]);
			zdwxy_2.setValue([]);
			zdwxy_3.setValue([]);
			zdwxy_5.setValue([]);
			zdwxy_6.setValue([]);
			zdwxy_7.setValue([]);

			zdwxy_8_chart_1.setValue([]);
			zdwxy_8_chart_2.setValue([]);


			$("#zdwxy_4_alarm_percent").flop({
				maxLength: 2,
				speed: 32,
				value: 78,
				suffix: "%",
				rich: false
			});

			$("#zdwxy_4_alarm_prev_month").flop({
				maxLength: 2,
				speed: 32,
				value: 234,
				rich: false
			});

			$("#zdwxy_4_alarm_next_month").flop({
				maxLength: 2,
				speed: 32,
				value: 234,
				rich: false
			});


			$("#zdwxy_5_num").flop({
				maxLength: 2,
				speed: 32,
				value: 178,
				rich: false
			});


			$("#zdwxy_8_flop_1").flop({
				maxLength: 4,
				speed: 32,
				value: "1000"
			});

			$("#zdwxy_8_flop_tab_1").flop({
				maxLength: 4,
				speed: 32,
				value: "2000"
			});

			$("#zdwxy_8_flop_tab_2").flop({
				maxLength: 4,
				speed: 32,
				value: "3000"
			});


			// 标签 切换
			$(".tab").each(function () {
				var $this = $(this);
				$this.on("click", "a", function (e) {
					e.preventDefault();
					var $a = $(e.target).is("a") ? $(e.target) : $(e.target).closest("a");
					if (!$a.parent().hasClass("tab-header")) {
						return;
					}
					var index = $this.find("a").index($a);
					$a.addClass("active").siblings().removeClass("active")
					$this.find(".tab-content .content").eq(index).addClass("active").siblings().removeClass("active");
				});
			});


		},
		listener: {

			"click::#dialog_1": function () {
				var dia = Firebird.ui.Dialog.open("fb-dv/zdwxy-dialog-1.html", {
					title: "",
					width: 1800,
					height: 760
				});
				dia.showModal();
			},
			"click::#dialog_2": function () {
				var dia = Firebird.ui.Dialog.open("fb-dv/zdwxy-dialog-2.html", {
					title: "",
					width: 1800,
					height: 760
				});
				dia.showModal();
			}


		},
		/**
		 * 在线列表
		 */
		showOnline: function () {
			var dia = Firebird.ui.Dialog.open("fb-dv/zdwxy-online.html", {
				title: "在线情况",
				width: 880,
				height: 677
			});
			dia.showModal();
		},

		showTodayAlarmStats: function () {
			var dia = Firebird.ui.Dialog.open("fb-dv/zdwxy-today-alarm-stats.html", {
				title: "在线情况",
				width: 880,
				height: 677
			});
			dia.showModal();
		}
	});


});